<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script src="<%=request.getContextPath()%>/ui/js/jquery.js"></script>
<%-- <script src="<%=request.getContextPath()%>/ui/js/paginate.js"></script> --%>
<%-- <script src="<%=request.getContextPath()%>/ui/js/customPaginate.js"></script> --%>
<script src="<%=request.getContextPath()%>/ui/js/jquery.dataTables.min.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/customDataTables.js"></script>

<%@include file="/ui/jsp/includes/header.jspf"%>

<div class="hero-unit secondary_container">
	<div id="table-subject-header">
		View Faculty List
	</div>
		<hr>


	<div class="row-fluid">
		<form method="POST" id="viewFacultyForm" >
			<div>

				<div class="addnew_button">
					<c:if test="${roleId==1 || roleId==3}">
						<input type="button" title="Add New Faculty Member" value="Add New" onclick="javascript:addNewFaculty()" class="btn btn-primary">
            			<input type="button" title="Display in a Print-Friendly Format" value="Print" onclick="javascript:printFacultyList()" class="btn btn-primary">
					</c:if>
					
				</div>
				<div class="span10">
					<table id='dataTableList' class="table table-striped table-bordered">
						<thead>
							<tr>
								<th width="8%">Action</th>
						
								<th>Faculty First</th>
								<th>Faculty Last</th>
								<th>Email</th>
								<th>Webpage</th>
								<th>Active</th>
								<th style="display:none;">N Number</th>
							</tr>
						</thead>
						<tbody>

							<c:forEach var="faculty" items="${facultyList}">
								<tr class="paginationList">
									<td><a
										href="javascript:viewFacultyDetails('${faculty.facultyId}')"><img
											src="<%=request.getContextPath()%>/ui/images/view.gif"
											title="View" /></a> <c:if
											test="${roleId==1 || roleId==3 || (roleId==2 && loginId == faculty.facultyId)}">
											<a
												href="javascript:viewFaculty('${faculty.facultyId}')"><img
												src="<%=request.getContextPath()%>/ui/images/edit.gif"
												title="Edit" /></a>
										</c:if>
									</td>
							
									<td>${faculty.firstName}</td>
									<td>${faculty.lastName}</td>
									<td>${faculty.email}</td>
									<td><a href="${faculty.webpageUrl}" target="_blank">${faculty.webpageUrl}</a></td>
									<td>${faculty.active}</td>
									<td style="display:none;">${faculty.nnumber}</td>
								</tr>
							</c:forEach>
						</tbody>

					</table>

					<div class="pagination"></div>

				</div>

			</div>
			<input type="hidden" id="facultyId" name="facultyId" value=""/>
		</form>
	</div>
	</div>
	<%@include file="/ui/jsp/includes/footer.jspf"%>

	<script language="javascript">
		function addNewFaculty() {
			$('#viewFacultyForm').attr('action', 'viewNewFaculty.html');
			$('#viewFacultyForm').submit();
		}
		function viewFaculty(facultyId) {
			$('#facultyId').val(facultyId);
			$('#viewFacultyForm').attr('action', 'viewExistingFaculty.html');
			$('#viewFacultyForm').submit();
		}
		function viewFacultyDetails(facultyId) {
			$('#facultyId').val(facultyId);
			$('#viewFacultyForm').attr('action', 'viewFacultyDetails.html');
			$('#viewFacultyForm').submit();
		}
		function printFacultyList(){
			window.open('printFacultyList.html');
		}
	</script>